import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
    server: {
        proxy: {
            "/api": {
                target: "http://127.0.0.1:4000",
                // 去掉/api
                rewrite: path => path.replace(/^\/api/, ""),
                // target是域名的话，需要这个参数
                changeOrigin: true
                // 设置支持https协议的代理
                // secure: false
            },
            "/mock-server": {
                target: "http://172.20.49.116:7001",
                rewrite: path => path.replace(/^\/mock-server/, ""),
                changeOrigin: true
            },
            "/_mock": {
                target: "http://172.20.49.116:7001",
                rewrite: path => path.replace(/^\/_mock/, "/request/admin-vue-pro"),
                changeOrigin: true
            }
        }
    },
    plugins: [vue()],
    resolve: {
        // 别名
        alias: {
            "@/": "/src/"
        }
    },
    css: {
        preprocessorOptions: {
            less: {
                javascriptEnabled: true
            }
        }
    }
})
